import axios from 'axios';
const baseUrl = `https://api.elma6524.com/v1/`
// 请求返回数据
export interface CodeBean<T> {
    code: number;
    data: T;
    message: string;
    msg: string;
}
export interface VerifyCode {
    checkToken: string;
    img: string;
    key: string;
    sensitive: boolean;
}
export interface UserInfo {
    account: string;
    balance: boolean;
    content: string;
    create_time: string;
    fifty: string;
    five: string;
    freeze: string;
    id: string;
    income: string;
    insure: string;
    invitation_code: string;
    notice: string;
    one_hundred: string;
    permissions: string;
    rate: number;
    thousand: string;
    two_hundred: string;
    wallet: string;
    withdrawal: string;

}
export abstract class PangHu {
    async verifyCode(): Promise<VerifyCode> {
        const res = await axios.get<CodeBean<VerifyCode>>(`${baseUrl}verifyCode`).then(res => res.data)
        if (res.code !== 200) {
            throw new Error(res.message || res.msg)
        }
        return res.data;
    }
    abstract recognize(img: string): string;
    async login(account: string, password: string, verifyCode: string) {
        
    }
    async userInfo(): Promise<UserInfo> {
        const res = await axios.get<CodeBean<UserInfo>>(`${baseUrl}userInfo`).then(res => res.data)
        if (res.code !== 200) {
            throw new Error(res.message || res.msg)
        }
        return res.data;
    }
}